name: my_fastapi_app
services:
  db:
    container_name: postgres_app
    image: postgres:latest
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASS}
      - POSTGRES_DB=${DB_NAME}
    ports:
      - "5433:5432"
    restart: always
    volumes:
      - /С/documents:/var/lib/backup/data

  tesseractpython:
    build: ./
    image: tesseractpython
    container_name: tesseractpython
    volumes:
      - /C/documents:/documents

  redis:
    image: redis:latest
    container_name: redis_app

  app:
    container_name: fastapi_app
    build: ./
    depends_on:
      - db
      - redis
    command: bash -c 'while !</dev/tcp/postgres_app/5432; do sleep 1; done; uvicorn app.main:app --host 0.0.0.0'
    ports:
      - 80:8000
    restart: always
    env_file:
      - .env
    volumes:
      - /C/documents:/documents

  celery:
    build: ./
    command: celery -A app.routers.documents_text:celery worker --loglevel=INFO
    depends_on:
      - app
      - redis
      - db
    env_file:
      - .env
    environment:
      - CELERY_BROKER_URL=redis://redis:6379/0
    volumes_from:
      - app

volumes:
  documents: